//
//  AnuseTableViewCell.m
//  Funny
//
//  Created by dllo on 15/10/30.
//  Copyright © 2015年 King. All rights reserved.
//

#import "AnuseTableViewCell.h"

@implementation AnuseTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.name = [[UILabel alloc]init];
        [self.contentView addSubview:self.name];
        
        self.commentnum = [[UILabel alloc]init];
        [self.contentView addSubview:self.commentnum];
        self.commentnum.textAlignment = NSTextAlignmentRight;
        self.commentnum.textColor = [UIColor grayColor];
        self.commentnum.font = [UIFont systemFontOfSize:14];
        
        self.content = [[UILabel alloc]init];
        [self.contentView addSubview:self.content];
        self.content.numberOfLines = 3;
        self.content.textColor = [UIColor grayColor];
        
        self.pic = [[UIImageView alloc]init];
        [self.contentView addSubview:self.pic];
        
        self.bgImg = [[UIImageView alloc]init];
        [self.pic addSubview:self.bgImg];
        [self.bgImg setImage:[UIImage imageNamed:@"image.png"]];
        
        self.address = [[UILabel alloc]init];
        [self.bgImg addSubview:self.address];
        self.address.font = [UIFont systemFontOfSize:13];
        self.address.textColor = [UIColor whiteColor];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    WeakSelf(weakSelf);
    self.pic.frame = CGRectMake(0, 0, SelfWidth, SelfWidth / 3 * 2);
    [self.address mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(weakSelf.pic);
        make.left.equalTo(weakSelf.pic).with.offset(20);
        make.size.mas_equalTo(CGSizeMake(335 * W, 20));
    }];
    [self.bgImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(weakSelf.pic).with.offset(-0);
        make.right.equalTo(weakSelf.pic.mas_right);
        make.size.mas_equalTo(CGSizeMake(SelfWidth, 30));
    }];
    self.name.frame = CGRectMake(10, SelfWidth / 3 * 2 + 5, 200, 30);
    self.commentnum.frame = CGRectMake(250 * W, SelfWidth / 3 * 2 + 5, 100, 30);
    self.content.frame = CGRectMake(10, SelfWidth / 3 * 2 + 25, 350 * W, 60);
}

- (void)setModel:(AnuseModel *)model
{
    self.name.text = model.name;
    self.address.text = [NSString stringWithFormat:@"地址:    %@",model.address];
    self.commentnum.text = [NSString stringWithFormat:@"%@ 条评论",model.commentnum];
    self.content.text = [NSString stringWithFormat:@"'%@'",model.impression];
    [self.pic sd_setImageWithURL:[NSURL URLWithString:model.pic] placeholderImage:[UIImage imageNamed:@"chartlet_image_traning@2x.png"]];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
